<script>
    function fibonacci(n) {
        var res1 = 1;
        var res2 = 1;
        var sum = res2;
        for (var i = 1; i < n; i++) {
            sum = res1 + res2;
            res1 = res2;
            res2 = sum;
        }
        return sum;
    }
    fibonacci(8)
    document.write(fibonacci(8))
        /****************************************************************/
    function fibonacci(n) {
        if (n <= 1) {
            return 1
        };
        return fibonacci(n - 1) + fibonacci(n - 2);
    }
</script>